package cn.tedu.feign;

import cn.tedu.pojo.Item;
import cn.tedu.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ItemClientFB implements ItemClient{
    @Override
    public JsonResult<List<Item>> getItem(String orderId) {

        if (Math.random()>0.5){
            //添加模拟缓存数据
            List<Item> list = new ArrayList<>();
            list.add(new Item(1, "碧玉刀", 2));
            list.add(new Item(2, "长生剑", 5));
            list.add(new Item(3, "泪痕箱", 3));
            list.add(new Item(4, "霸王枪", 5));
            list.add(new Item(5, "明月勾", 41));
            return JsonResult.ok().data(list);
        }
        return JsonResult.err().msg("获取商品类列表失败");
    }

    @Override
    public JsonResult decreaseNumber(List<Item> items) {
        return JsonResult.err().msg("减少商品库存失败");
    }
}
